FROM golang:alpine as builder

WORKDIR /go/src/live-find
COPY go.mod .
COPY go.sum .

ENV  GO111MODULE=on GOPROXY=https://goproxy.cn,direct 
RUN go generate \
  && go env

COPY . .
RUN  go install github.com/swaggo/swag/cmd/swag && swag init && go build -o server .

FROM alpine:latest
LABEL MAINTAINER="scb@jdinfotech.com"

WORKDIR /live-find

COPY --from=builder /go/src/live-find/server ./

RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.ustc.edu.cn/g' /etc/apk/repositories \
  && apk add tzdata \
  && cp  /usr/share/zoneinfo/Asia/Shanghai /etc/localtime \
  && echo "Asia/Shanghai" > /etc/timezone \
  && apk del tzdata 

EXPOSE 8888

CMD ["/bin/sh"]
